package com.gexin.model.activity;

import com.gexin.common.utils.SQLUtils;
import com.gexin.model.activity.base.BaseFreeAcquire;
import com.jfinal.plugin.activerecord.Page;

import java.util.List;

/**
 * 业务名称:  t_free_acquire() 
 */
@SuppressWarnings("serial")
public class FreeAcquire extends BaseFreeAcquire<FreeAcquire> {
	public static final FreeAcquire dao = new FreeAcquire();


	public Page<FreeAcquire> findActivityByTime(int page, int pageSize){
		SQLUtils sql = new SQLUtils(" from  t_free_acquire freeac join t_activity activity " +
				"on freeac.activity_id=activity.id where now() between activity.activity_start_time and activity.activity_end_time" +
				" and activity.type=1");

		return paginate(page,pageSize,"select freeac.*",sql.toString());
	}

	public List<FreeAcquire> getAllCheckProduct()
	{
		SQLUtils sqlUtils = new SQLUtils("select * from t_free_acquire");
		List<FreeAcquire> ms = ((BaseFreeAcquire)dao()).find(sqlUtils.toString());
		return ms;
	}
	public FreeAcquire findFreeAcquireByTime(){
		SQLUtils sql = new SQLUtils("select * from  t_free_acquire freeac join t_activity activity " +
				"on freeac.activity_id=activity.id where now() between activity.activity_start_time and activity.activity_end_time" +
				" and activity.type=1");
		return dao.findFirst(sql.toString());
 	}
}
